
// 发送ajax请求获取数据
axios.post(
    'http://39.98.112.34:8000/introduction/index',
      {page:1,pageSize:6}
).then((res) => {
    let response = res.data;
    console.log(res)
    let html = '';
    response.data.forEach(function (item) {
            html += `
                <a href='detail.html?id=${item.id}'>
                    <dl>
                    <dt><img src="${item.coverImg}" alt=""></dt>
                    <dd><h3>${item.cityName}</h3></dd>
                    <dd><p>${item.content}</p></dd>
                    </dl>
                </a>
    `
    })
    document.querySelector('.content').innerHTML = html;
});
//解码decodeURIComponent
let userInfo = getCookie('userInfo') ? JSON.parse(decodeURIComponent(getCookie('userInfo'))) : null;
if (userInfo) {
    // 登录状态
    document.querySelector('.resgist').innerHTML = `${userInfo.nickname} 欢迎`
    //退出按钮
    document.querySelector('.out').addEventListener('click', () => {
        //删除cookie
        removeCookie('userInfo');
        //重新加载
        location.reload();
    })
} else {
    document.querySelector('.resgist').innerHTML = '<a href="login.html">登录</a>'
}